package 数据排列;

//将数组数据按照大或小顺序排列
public class shunxu {
    public static void main(String[] args) {
        int[] arr = {1, 2, 11, 4, 7, 3, 5};
        prin(arr);
        prin1(arr);
    }

    //小到大排列
    public static void prin(int[] arr) {
        for (int i = 0; i < arr.length; i++) {
            for (int i1 = i + 1; i1 < arr.length; i1++) {
                if (arr[i] > arr[i1]) {
                    int num = arr[i];
                    arr[i] = arr[i1];
                    arr[i1] = num;
                }
            }
            System.out.print(arr[i] + "\t");
        }
        System.out.println("\n");
    }
    //大到小排列
    public static void prin1(int[] arr) {
        for (int i = 0; i < arr.length; i++) {
            for (int i1 = i + 1; i1 < arr.length; i1++) {
                if (arr[i] < arr[i1]) {
                    int num = arr[i];
                    arr[i] = arr[i1];
                    arr[i1] = num;
                }
            }
            System.out.print(arr[i] + "\t");
        }
        System.out.println("\n");
    }
}
